home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbbook13
/
vbbinp13.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
31KB
|
889 lines
VERSION 2.00
Begin Form VBBinp
BackColor = &H00FF8080&
Caption = "VB Book Input"
ClientHeight = 5595
ClientLeft = 1260
ClientTop = 1545
ClientWidth = 5640
Height = 6000
Icon = VBBINP13.FRX:0000
Left = 1200
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 5595
ScaleWidth = 5640
Top = 1200
Width = 5760
Begin Frame Outname
BackColor = &H008080FF&
Caption = "Output To:"
Height = 855
Left = 3180
TabIndex = 11
Top = 4560
Width = 2235
Begin ComboBox comboutname
BackColor = &H00C0C0C0&
Height = 300
Left = 60
TabIndex = 8
Top = 360
Width = 2115
End
End
Begin DirListBox Dir1
BackColor = &H00C0C0C0&
Height = 2535
Left = 240
TabIndex = 6
Top = 2880
Width = 2895
End
Begin FileListBox File1
BackColor = &H00C0C0C0&
Height = 1980
Left = 3720
TabIndex = 7
Top = 2520
Width = 1695
End
Begin DriveListBox Drive1
BackColor = &H00C0C0C0&
Height = 315
Left = 240
TabIndex = 5
Top = 2520
Width = 2895
End
Begin CheckBox Clk6
Caption = "A2 (American) Paper or A4 if off"
Height = 255
Left = 360
TabIndex = 15
Top = 2040
Value = 1 'Checked
Width = 3255
End
Begin ComboBox Linelength
BackColor = &H00C0C0C0&
Height = 300
Left = 4260
TabIndex = 13
Top = 1740
Width = 1035
End
Begin CheckBox clk5
Caption = "Set Line Wrap On"
Height = 255
Left = 360
TabIndex = 4
Top = 1680
Value = 1 'Checked
Width = 3255
End
Begin TextBox Text1
BackColor = &H00FF8080&
BorderStyle = 0 'None
Enabled = 0 'False
Height = 195
Left = 4260
MultiLine = -1 'True
TabIndex = 14
Text = "Text Width:"
Top = 1500
Width = 1035
End
Begin CheckBox clk4
Caption = "Use Speaker"
Height = 255
Left = 360
TabIndex = 3
Top = 1320
Value = 1 'Checked
Width = 3255
End
Begin CheckBox clk3
Caption = "Print Page Numbers"
Height = 255
Left = 360
TabIndex = 2
Top = 960
Value = 1 'Checked
Width = 3255
End
Begin PictureBox Picture1
BackColor = &H00FF8080&
Height = 495
Left = 4500
Picture = VBBINP13.FRX:0302
ScaleHeight = 465
ScaleWidth = 465
TabIndex = 12
Top = 660
Width = 495
End
Begin CheckBox clk2
Caption = "Print Date/Time on each Page"
Height = 255
Left = 360
TabIndex = 1
Top = 600
Value = 1 'Checked
Width = 3255
End
Begin CommandButton go
Caption = "Do It"
Default = -1 'True
Height = 375
Left = 4800
TabIndex = 9
Top = 240
Width = 735
End
Begin CommandButton Cancel
Caption = "Cancel"
Height = 375
Left = 3960
TabIndex = 10
Top = 240
Width = 735
End
Begin CheckBox clk1
BackColor = &H00FFFFFF&
Caption = "Print Filename on each Page"
ForeColor = &H00000000&
Height = 255
Left = 360
TabIndex = 0
Top = 240
Value = 1 'Checked
Width = 3255
End
End
Dim ESC$, FF$, LF$, filename$, outfile$, NewName$, NL$
Dim Page%, num$, tune%
Dim PC As Flags
Dim PaperAmerican
Dim PaperWidth
Dim ToAFile
Dim LeftSide%, RightSide%, FirstPass%
Dim Bookmark%, Junk%, Abort%
Dim Default$, Title$, Msg$
Dim lastchange As Integer
Const fileboxclick = 0, dirsboxclick = 1
Const True = -1, False = 0
Sub BuildArray (ptrarray&(), pgcount%)
'Was Satic Sub ...
MaxLines% = 66 'Maximum number of lines
Offset& = 1 'Start of file (seek point)
Open filename$ For Binary Access Read As #1 Len = 1 'Open file to check
TotalSize& = LOF(1) 'Get LEN of file so we don't read too far
FileLeft& = TotalSize& 'Setup a counter to show whats left
'FRE is not supported by VB. Use GetFreeSpace() instead (see global module)
memAvail& = GetFreeSpace(0) '65536 FRE(FileName$) - 2048 'Check available string memory
If memAvail& < 2048 Then Error 14 'Force out of memory error
SixteenK% = 16384
If TotalSize& > SixteenK% Then 'Set a buffer size
If memAvail& > SixteenK% Then 'If the file is larger than 16K
BufAvail& = SixteenK% 'Set it to 16k
Else
BufAvail& = memAvail&
End If
Else
If TotalSize& < memAvail& Then 'Otherwise set it to file size
BufAvail& = TotalSize&
End If
BuffSize% = BufAvail&
End If
pgcount% = 1 'Initialize page count
ptrarray&(pgcount%) = 1 'First pointer is always 1
LnCount% = 0 'Initialize line count
GetPage: 'Read the file
If FileLeft& < BufAvail& Then 'Check amount left to read
Buffer$ = Space$(FileLeft&) 'If less than our buffer, use lessor
Else
Buffer$ = Space$(BufAvail&) 'Otherwise use full buffer size
End If
Get #1, Offset&, Buffer$ 'Read in a buffers worth
stptr% = 1 'Pointer into buffer$
LastLine% = 0 'remember last position
PageCheck:
Junk% = DoEvents() 'yield some time to the system
TempLn% = InStr(stptr%, Buffer$, LF$) 'Position of next linefeed
temppg% = InStr(stptr%, Buffer$, FF$) 'Position of next pagefeeds
If temppg% Then 'If there was a page feed
If temppg% < TempLn% Or TempLn% = 0 Then ' was it before our linefeed?
pgcount% = pgcount% + 1 ' yes then bump page count
ptrarray&(pgcount%) = Offset& + temppg% ' set next array element
stptr% = temppg% + 1 ' set instr pointer
LnCount% = 0 ' reset linecount
If stptr% < Len(Buffer$) Then GoTo PageCheck 'and loop back for more
End If
End If
If TempLn% Then 'Line